/**
 * 
 */
package com.cadang.android.bbrproject.util;

import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.util.Log;

/**
 * @author Cadang
 *
 */
public class MakeSlideShow extends AsyncTask<String, Integer, String[]> {
	
	private OnMakeSlideListener mListener;	
	@Override
	protected String[] doInBackground(String... url) {
		// TODO Auto-generated method stub
		String result = null;
		InputStream is = null;
		try{
    		HttpURLConnection con = (HttpURLConnection) new URL(url[0]).openConnection();
    		con.connect();
    		is = con.getInputStream();	    	    

		}catch(Exception e){
            Log.e("log_tag", "Error in http connection "+e.toString());
            return null;
		}
	    
		//convert response to string
		try{
            BufferedReader reader = new BufferedReader(new InputStreamReader(is,"utf-8"),8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                    sb.append(line + "\n");
            }
            is.close();
            result=sb.toString();
            Log.d("Slide List", result);
		}catch(Exception e){
            Log.e("log_tag", "Error converting result "+e.toString());
            return null;
		}
		return result.split("\"");		
	}
	@Override
	protected void onPostExecute(String[] result){
		
		mListener.onMakeSlideCompelted(result);
	}
	public void setMakeSlideListener(OnMakeSlideListener _slide){
		mListener = _slide;
	}
	
}
